package com.exp3;

import java.util.regex.Pattern;

/**
 * <p>Title: Regs</p>
 * <p>Description: 封装正则表达式</p>
 * @author 詹金浩
 * @date 2018年10月21日
 */
public class Regs {
	
	//航班唯一标识
	public static final String FLID = "((flid=){1})\\d{7}";

	//航班标识
	public static final String FFID = "((ffid=){1})\\w{2}-\\w{3,6}-\\d{8}-\\w";
	
	//结束登机时间
	public static final String POKT = "((pokt=){1})(\\d{14}|null)";

	//预计起飞时间
	public static final String FETT = "((fett=){1})(\\d{14}|null)";

	//实际起飞时间
	public static final String FRTT = "((frtt=){1})(\\d{14}|null)";
	
	//值机柜台
	public static final String CODE = "((code=){1})[A-Z]\\d{2}";
	
	//航班号
	public static final String FLNO = "((flno=){1})[A-Za-z0-9]{3,6}";
	
	//出发地
	public static final String ARNO1 = "((1, apcd=){1})(\\w{3,4}|null)";
	
	//经停地
	public static final String ARNO2 = "((2, apcd=){1})(\\w{3,4}|null)";
	
	//目的地
	public static final String ARNO3 = "((3, apcd=){1})(\\w{3,4}|null)";
	
	//共享航班号
	public static final String SFNO = "((sfno=){1})[A-Za-z0-9]{3,6}";
	
	/**
	 * <p>Title: get</p>
	 * <p>Description: 获得相应的Pattern</p>
	 * @param regName，正则表达式对应的属性名
	 * @return	Pattern
	 * @throws Exception
	 */
	public Pattern get(String regName) throws Exception {
		Class clazz = Class.forName("com.exp3.Regs");
		String reg = (String) clazz.getField(regName).get(regName);
		return changeToPattern(reg);
	}
	
	//编译正则表达式
	private static Pattern changeToPattern(String reg) {
		return Pattern.compile(reg);
	}
}